import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { Role } from '../../entities/role.entity';
import { PageOptionsDto } from '../page.dto';

export class UserRegisterDto {
  @ApiProperty({
    required: false,
    description: '用户id',
  })
  @IsString()
  @IsOptional()
  id?: string;
  @IsNotEmpty({
    message: '账户名称不能为空',
  })
  @ApiProperty({
    example: 'admin',
    description: '账户名',
  })
  account: string;

  @IsNotEmpty({
    message: '用户密码不能为空',
  })
  @ApiProperty({
    example: 'admin',
    description: '用户密码',
  })
  password: string;

  @IsNotEmpty({
    message: '用户昵称不能为空',
  })
  @ApiProperty({
    example: '系统管理员',
    description: '用户昵称',
  })
  username: string;
  @ApiProperty({
    example: '',
    description: '用户头像',
  })
  avatar?: string;

  @ApiProperty({
    example: '',
    description: '用户性别',
  })
  six?: string;

  @IsString()
  @ApiProperty({
    example: [],
    description: '用户角色',
  })
  roleIds: Partial<Role>[];
}

export class UpdatePasswordDto {
  @ApiProperty({
    required: false,
    description: '用户id',
  })
  @IsString()
  @IsOptional()
  id?: '';
  @IsOptional()
  @ApiProperty({
    example: '',
    required: false,
    description: '原用户密码',
  })
  password: string;
  @IsOptional()
  @ApiProperty({
    example: '',
    required: false,
    description: '新密码',
  })
  confirmPassword: string;
}
export class PageSearchUserDto extends PageOptionsDto {
  @ApiProperty({
    required: false,
    description: '用户id',
  })
  @IsString()
  @IsOptional()
  id?: '';

  @IsOptional()
  @ApiProperty({
    example: '',
    required: false,
    description: '账户名',
  })
  account: string;

  @IsOptional()
  @ApiProperty({
    example: '',
    required: false,
    description: '用户密码',
  })
  password: string;

  @IsOptional()
  @ApiProperty({
    example: '',
    required: false,
    description: '用户昵称',
  })
  username: string;
  @IsOptional()
  @ApiProperty({
    example: '',
    required: false,
    description: '性别',
  })
  sex: string;

  @IsOptional()
  @IsString()
  @ApiProperty({
    example: [],
    required: false,
    description: '用户角色',
  })
  roleIds: Partial<Role>[];
}
